package com.norman.sorry.core.tiles;

/**
 * A factory class that provides methods to creating different types of tiles.
 * 
 * @author Brian Norman
 * @version 0.0.1 beta
 * @since 0.0.1 beta
 */
public class LinkedTileFactory implements ITileFactory<AbstractLinkedTile> {

   /**
    * {@inheritDoc}
    * 
    * @see ITileFactory#createTile()
    */
   @Override
   public AbstractLinkedTile createTile() {
      return create(false, false, false);
   }

   /**
    * {@inheritDoc}
    * 
    * @see ITileFactory#createSafeTile()
    */
   @Override
   public AbstractLinkedTile createSafeTile() {
      return create(false, true, false);
   }

   /**
    * {@inheritDoc}
    * 
    * @see ITileFactory#createStart()
    */
   @Override
   public AbstractLinkedTile createStart() {
      return new AbstractLinkedTile(true, true, false) {
         @Override
         public boolean containsPiece() {
            return false;
         }
      };
   }

   /**
    * {@inheritDoc}
    * 
    * @see ITileFactory#createHome()
    */
   @Override
   public AbstractLinkedTile createHome() {
      return new AbstractLinkedTile(false, true, true) {
         @Override
         public boolean containsPiece() {
            return false;
         }
      };
   }

   /**
    * {@inheritDoc}
    * 
    * @see ITileFactory#create(boolean, boolean, boolean)
    */
   @Override
   public AbstractLinkedTile create(boolean start, boolean safe, boolean home) {
      return new LinkedTile(start, safe, home);
   }

   /**
    * Private concrete class for creating new instances of a linked tile.
    */
   private static final class LinkedTile extends AbstractLinkedTile {
      public LinkedTile(boolean start, boolean safe, boolean home) {
         super(start, safe, home);
      }
   }

}
